[hellojoyworldz] WEEK 02 solutions#2697
Merged
Merged
Conversation
Contributor
📊 hellojoyworldz 님의 학습 현황이번 주 제출 문제
누적 학습 요약
문제 풀이 현황
🤖 이 댓글은 GitHub App을 통해 자동으로 작성되었습니다. 🔢 API 사용량 (gpt-5-nano)
|
parkhojeong
approved these changes
Jul 4, 2026
Comment on lines
+5
to
+8
| class Solution: | ||
| def isAnagram(self, s: str, t: str) -> bool: | ||
| return sorted(s) == sorted(t) | ||
|
|
Comment on lines
+19
to
+21
| for i in reversed(range(n)): | ||
| answer[i] *= right | ||
| right *= nums[i] |
Contributor
There was a problem hiding this comment.
reversed(range(n)) 사용하신거 간결하고 좋네요~
| prev2, prev1 = 1, 1 | ||
| for _ in range(n - 1): | ||
| prev2, prev1 = prev1, prev2 + prev1 | ||
| return prev1 |
Contributor
There was a problem hiding this comment.
개인적으로는 이런 부분들이 읽으면서 생각을 한 번 더 하게 되었던 거 같습니다!
- prev2, prev1에 1, 1 이 할당된 것도 문제의 조건과 어떻게 연결되는건지
- n = 1, n = 2 일때 어떻게 처리되는지
- prev1이 리턴하는게 n 값 까지 계산한 후 prev1 을 리턴하는 것인지
가독성을 고려한다면 배열을 사용해봐도 괜찮을 거 같습니다~
class Solution:
def climbStairs(self, n: int) -> int:
if n == 1:
return 1
arr = [0] * n
arr[0], arr[1] = 1, 2
for i in range(2, n):
arr[i] = arr[i - 1] + arr[i - 2]
return arr[-1]
Contributor
Author
There was a problem hiding this comment.
안 그래도 가독성 부분이 고민이였는데,
제안해 주신 것처럼 배열을 쓰니까 흐름이 훨씬 직관적이고 좋네요!
Comment on lines
+13
to
+15
| for i in range(len(nums)): | ||
| if i > 0 and nums[i] == nums[i - 1]: | ||
| continue |
Contributor
There was a problem hiding this comment.
정렬되어 있는 상태라 nums[i] > 0 인 부분은 break해도 좋을 거 같습니다!
ex. [-1, 0, 1, 2, 3, 4, 5, 6, 7], i = 2 부터는 양수 + 양수 + 양수
Contributor
Author
There was a problem hiding this comment.
아 그러네요, 제가 놓쳤습니다
세심한 피드백 정말 감사합니다! 🙇♂️
Comment on lines
+20
to
+21
| if not (low < node.val < high): | ||
| return False |
Contributor
There was a problem hiding this comment.
(log < node.val < high) 사용하신거 좋네요!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
답안 제출 문제
작성자 체크 리스트
In Review로 설정해주세요.검토자 체크 리스트
Important
본인 답안 제출 뿐만 아니라 다른 분 PR 하나 이상을 반드시 검토를 해주셔야 합니다!